<template>
  <van-address-list :switchable="true" :checked="true" :list="address.list" v-model="chosenAddressId"
    default-tag-text="默认" @select="handleChange" @add="onAdd" @edit="onEdit" />


</template>

<script setup lang="ts">
import { ref } from 'vue';
import { Toast } from 'vant';
import { useRoute, useRouter } from 'vue-router';
import { useAddress } from '../../store/user'

export interface AddressType {
  name: string,
  address: string,
  id: string,
  tel: string,
  isDefault: boolean
}
export interface AddressState {
  List: AddressType
}

const address = useAddress();
const route = useRoute()
const router = useRouter()
const chosenAddressId = ref('0');
// const list = [
//   {
//     id: '1',
//     name: '张三',
//     tel: '13000000000',
//     address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
//     isDefault: true,
//   },
//   {
//     id: '2',
//     name: '李四',
//     tel: '1310000000',
//     address: '浙江省杭州市拱墅区莫干山路 50 号',
//   },
// ];
// const disabledList = [
//   {
//     id: '3',
//     name: '王五',
//     tel: '1320000000',
//     address: '浙江省杭州市滨江区江南大道 15 号',
//   },
// ];
//新增
const onAdd = () => {
  router.push(`/addressdel/${-1}`)
};
//编辑更新
const onEdit = (item: AddressType, index: number) => {
  router.push(`/addressdel/${index}`)
};
//用户切换地址
const handleChange = (item: AddressType, index: number) => {
  router.push(`/confirmord/${index}`)
}
</script>

<style lang="scss" scoped>

</style>